1 Research question

This assignment will explore the question:

How have global average temperatures changed overtime?

It will specifically look at data for global average temperatures relative to the average temperature for the period between 1961 and 1990.

2 Data set Introduction

The data used in this assignment is from Ritchie etal., 2020, and can be found at Our World in Data. It contains global average temperatures relative to the average temperature for the time period between 1961 and 1990, for the Entire Globe; the Southern Hemisphere; and the Northern Hemisphere, from 1850 to 2023.

The variables contained in this data set are shown below in Table 2.1 - Variable Names. The variable Entity contains categorical information of either Global, Northern Hemisphere or Southern Hemisphere, meanwhile the variable year contains values from 1850 to 2023. All other variables are described in Table 2.1.

# table of variable names
kable(names(temperature_anomaly),caption = "Variable Names", col.names = 'Names') %>%
  kable_styling()
Table 2.1: Variable Names
Names
Entity
Year
Global average temperature anomaly relative to 1961-1990
Upper bound of the annual temperature anomaly (95% confidence interval)
Lower bound of the annual temperature anomaly (95% confidence interval)

3 Data set description

The data set contains 5 variables as outlined in Section 2 - Data set Introduction above and 522 observations. The inline code for the previous sentence can be seen below in Figure 3.1.

# show image of inline code
include_graphics("Image/Description_size_of_data.png")
Image of the inline code for data description

Figure 3.1: Image of the inline code for data description

The variable types for the first two observations in the data set are displayed below.

str(head(temperature_anomaly,2))
## tibble [2 × 5] (S3: tbl_df/tbl/data.frame)
##  $ Entity                                                                 : chr [1:2] "Global" "Global"
##  $ Year                                                                   : num [1:2] 1850 1851
##  $ Global average temperature anomaly relative to 1961-1990               : num [1:2] -0.418 -0.233
##  $ Upper bound of the annual temperature anomaly (95% confidence interval): num [1:2] -0.2461 -0.0548
##  $ Lower bound of the annual temperature anomaly (95% confidence interval): num [1:2] -0.589 -0.412

The above information shows that the variable Entity is a character variable meanwhile the remaining four variables are all numeric.

4 Data Summary

measure_mean<-temperature_anomaly %>%
  select(-Year) %>%
  group_by(Entity) %>%
  summarise_all(mean)

colnames(measure_mean)<-c("Entity","Mean Global Average Temperature","Mean Upper Bound Average Temperature", "Mean Lower Bound Average Temperature")


measure_median<-temperature_anomaly %>%
  select(-Year) %>%
  group_by(Entity) %>%
  summarise_all(median)

colnames(measure_median)<-c("Entity","Median Global Average Temperature","Median Upper Bound Average Temperature", "Median Lower Bound Average Temperature")

measures <- merge(measure_mean, measure_median) %>%
  select(1,2,5,3,6,4,7)


kable(measures ,caption = "Mean and Median for Global Average Temperatures including the Upper and Lower Bounds.") %>%
  kable_styling(bootstrap_options = c('bordered',"hover")) %>%
  column_spec(2:3,background = '#cbcbcb') %>%
  column_spec(6:7,background = '#cbcbcb') 
Table 4.1: Mean and Median for Global Average Temperatures including the Upper and Lower Bounds.
Entity Mean Global Average Temperature Median Global Average Temperature Mean Upper Bound Average Temperature Median Upper Bound Average Temperature Mean Lower Bound Average Temperature Median Lower Bound Average Temperature
Global -0.0727916 -0.1755711 0.0250166 -0.0746874 -0.1705997 -0.2613263
Northern hemisphere -0.0206968 -0.1166910 0.0861322 -0.0207820 -0.1275258 -0.2023924
Southern hemisphere -0.1248863 -0.2289955 0.0055675 -0.0867496 -0.2553402 -0.3925451

Table 4.1 shows the mean and median global average temperatures including the upper and lower bound temperature values. The values in this table indicate that the mean temperatures are slightly higher than the median and the Northern Hemisphere is slightly warmer than the Southern Hemisphere.

5 Visualisations

Below in Figure 5.1 are graphs of average temperatures with their Upper and Lower values from 1850 until 2023, for the entire Globe;the Northern Hemisphere and the Southern Hemisphere.

colnames(temperature_anomaly)[3]="Global Average Temperature"
colnames(temperature_anomaly)[4]="Lower Bound"
colnames(temperature_anomaly)[5]="Upper Bound"
temp<-temperature_anomaly %>% pivot_longer(cols = 3:5, names_to = "Type", values_to = "number")
p<-ggplot(temp,aes(x=Year, y=number, color =Type))+geom_point()+geom_line()+
  scale_colour_manual(values = c("#2375b3","grey","grey"))+
  theme(axis.line = element_line(linetype = 'solid'))+
  labs(y="Average Temperature Anomaly relative to 1961 - 1990")+
  geom_hline(yintercept = 0, color = 'grey')+
  facet_grid(Entity~.)
p<-ggplotly(p) %>%
  layout(legend=list(orientation='h'))
p

Figure 5.1: Average Temperature Anomly relative to average temperature between 1961 -1990’ from 1850 to 2023

6 References

Ritchie, H., Roser, M., & Rosado, P. (2020, May 11). CO₂ and greenhouse gas emissions. Our World in Data. https://ourworldindata.org/co2-and-greenhouse-gas-emissions